﻿using NB.MGJ.Cache;
using NB.MGJ.Model;
using NB.MGJ.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Common.Cache
{
    public static partial class MGJCache
    {
        #region 菜单信息
        //获取整个表信息
        public static List<Sys_Menu> GetMenuInfoList(string sql)
        {
            return CacheManager.Get<List<Sys_Menu>>(CacheKey.Key_AllMenuInfoList, () =>
            {
                return new CommonService().GetAllMenuInfoList(sql);
            });
        }

        /// <summary>
        /// 主动更新菜单缓存信息
        /// </summary>
        public static void UpdateMenuCache(string sql)
        {
            var _list = new CommonService().GetAllMenuInfoList(sql);
            CacheManager.Remove(CacheKey.Key_AllMenuInfoList);
            CacheManager.Set(CacheKey.Key_AllMenuInfoList, _list);
        }

        #endregion
    }
}
